package com.java.simple.study.jvm.memstruct.heap;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author zhoujunlin
 * @date 2022年06月14日 16:55
 * @desc -Xms600m -Xmx600m
 */
public class OOMTest {

    public static void main(String[] args) {
        // 不被垃圾回收 最后oom
        List<Picture> pictures = new ArrayList<>();
        while (true) {
            try {
                Thread.sleep(20);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            pictures.add(new Picture(new Random().nextInt(1024 * 1024)));
        }
    }

}


class Picture {
    private byte[] pixels;

    public Picture(int length) {
        this.pixels = new byte[length];
    }
}
